// 密钥组件，装上可用
const app = getApp()
const db = wx.cloud.database()
Component({
  data: {
    on: false,
    password:"",
  },
  pageLifetimes: {
    show: function() {
      db.collection("password").get({
        success:(res)=>{
          this._password=res.data[0].password
        }
      })
    },
    
  },
  methods: {
    
    //把窗体显示出来
    show() {
      this.setData({
        on: true,
      })
    },
    shutShare() {
      wx.showToast({
        title: '成功',
        icon: 'success',
        duration: 1500,
        mask: true,
        complete: () => {
          this.setData({
            on: false,
          })
        }
      })
      this.animate(".span", [{
        opacity: 1
      }, {
        opacity: 0
      }], 100)
      this.animate(".zhezhao", [{
        opacity: 0.6
      }, {
        opacity: 0
      }], 100)
    },
    shut(){
      if(this.data.password===this._password){
        this.shutShare()
          wx.navigateTo({
            url: '../../otherTap/pages/management/management',
          })
      }else{
        wx.showToast({
          title: '密钥错误',
          icon: 'error',
          duration: 1000,
        })
      }
    },
    cancel(){
      wx.showToast({
        title: '已取消',
        icon: 'success',
        duration: 1000,
        mask: true,
        complete: () => {
          this.setData({
            on: false,
          })
        }
      })
    },
    nothing(){},
    preventdefault(){}
  }
})